package com.lanyun.serviceimpl;

import com.lanyun.dao.ProcurementDao;
import com.lanyun.dao.Procurement_etailsDao;
import com.lanyun.dao.ProductDao;
import com.lanyun.dao.Product_supplierDao;
import com.lanyun.pojo.*;
import com.lanyun.service.Procurement_etailsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class Procurement_etailsServiceImpl implements Procurement_etailsService {

    @Autowired
    private Procurement_etailsDao procurement_etailsDao;
    @Autowired
    private ProcurementDao procurementDao;
    @Autowired
    private Product_supplierDao product_supplierDao;
    @Autowired
    private ProductDao productDao;


    // 通过采购订单ID 获取到订单详情相关信息
    @Override
    public List<Procurement_etails> GetProcurementsByID(Integer id) {
        return procurement_etailsDao.GetProcurementsByID(id);
    }

    // 通过成功提交的申请采购表 将数据进行存入
    @Override
    public int addprocurement(String id, String lists, String amounts, String xxx) {

        return procurement_etailsDao.addprocurement(id,lists,amounts,xxx);
    }

    // 通过详情单商品ID 和 供应商ID 获取到具体的价格
    @Override
    public Product_supplier GetPrice(Integer id, Integer ids) {
        return product_supplierDao.GetPrice(id,ids);
    }

    @Override
    public Product_supplier GetPrices(String id, String ids) {
        return product_supplierDao.GetPricess(id,ids);
    }

    @Override
    public Product GetProductByID(Integer id) {
        return productDao.GetProductByID(id);
    }

    @Override
    public Procurement_etails GetProcurement_etails(String id) {
        return procurement_etailsDao.GetProcurement_etails(id);
    }

    // 数量发生变化时 修改详情表的数量
    @Override
    public Integer updataProcurement_etails(Integer id, String much) {
        return procurement_etailsDao.updataProcurement_etails(id,much);
    }

    // 采购订单没有关联的采购详情表 给予删除
    @Override
    public Integer RemoveProcurement_etailsByID(String id) {
        return procurement_etailsDao.RemoveProcurement_etailsByID(id);
    }

    // 修改详情订单最后的状态
    @Override
    public Integer updateEnd(String status,String id) {
        return procurement_etailsDao.updateEnd(status,id);
    }

    // 通过主表ID 查询出关联表中未入库详情单的总数
    @Override
    public Integer Count(String id) {
        return procurement_etailsDao.Count(id);
    }
}
